home *** CD-ROM | disk | FTP | other *** search
- situation planet_production
- vars
- p : planet;
- i : integer;
- st : integer;
- success : boolean;
- hex : integer;
- struct : structure;
-
- function Find_empty_hex(p : planet) : integer;
- vars
- target : integer;
-
- begin
- target := Random(127);
- while (Hex_structure(p, target) <> nil) do
- target := Random(127);
- return(target);
- end;
-
-
- // Main function
- begin
- p := This_planet();
- // First set the tech spending levels
- Set_weapon_spending(p, w_spending);
- Set_shield_spending(p, s_spending);
- Set_move_spending(p, m_spending);
- Set_detect_spending(p, d_spending);
- Set_develop_spending(p, 50);
- // Now see if we want to build a ship
- if ((Planet_weapon(p) > tech_min) and
- (Planet_shield(p) > tech_min) and
- (Planet_move(p) > tech_min) and
- (Planet_detect(p) > tech_min)) then
- Set_ship_spending(p, 100);
- else
- Set_ship_spending(p, 0);
-
- // If there are more then two ships, then send out a squad
- if (Orbit_num_ships(p) >= 3) then
- begin
- i := 1; // Don't want to send starbase
- while (i < Orbit_num_ships(p)) do
- begin
- success := Orbit_depart(p, i, true);
- i := i + 1;
- end;
- end;
-
- // If a new ship has been built then set the ship type
- if (New_ship(p)) then
- begin
- i := 0;
- while (Can_build_ship_type(p, i)) do
- i := i + 1;
- if (i > 0) then
- begin
- st := Random(i);
- success := Construct_ship_type(p, st);
- end;
-
- // Now set the troops to fill it
- i := 0;
- while (i < 8) do
- begin
- success := Stardock_set_manifest(p, i, 0);
- i := i + 1;
- end;
- // Now refill the barracks
- success := true;
- while (success) do
- begin
- i := Random(7) + 1;
- while (not Can_build_troop(p, i)) do
- i := Random(7) + 1;
- success := Stardock_set_manifest(p, i, Stardock_get_manifest(p, i)+1);
- end;
- end;
-
- // If there are 0 projects, then build a barracks or space port.
- if (Num_projects(p) = 0) then
- begin
- if (Num_structures(p, 10) < 6) then // space port
- begin
- // Select a random hex
- hex := Find_empty_hex(p);
- success := Create_structure(p, hex, 10);
- end;
- if (Num_structures(p, 2) < 6) then // barracks
- begin
- // Select a random hex
- hex := Find_empty_hex(p);
- success := Create_structure(p, hex, 2);
- end;
- end;
-
- // See if we need to reorganize the barracks
- if (New_troop(p)) then
- begin
- struct := First_structure(p);
- while (struct <> nil) do
- begin
- if ((Structure_type(p, struct) = 2) and
- (Structure_left(p, struct) = 0)) then
- begin
- // Clear the old troops in the barracks
- i := 1;
- while (i < 8) do
- begin
- success := Set_barracks(p, struct, i, 0);
- i := i + 1;
- end;
- // Now refill the barracks, try one of each
- i := 7;
- while (i > 1) do
- begin
- if (Can_build_troop(p, i)) then
- success := Set_barracks(p, struct, i, Get_barracks(p, struct, i)+1);
- i := i - 1;
- end;
- end;
- struct := Next_structure(p, struct);
- end;
- end;
- end;
-
-
-
-
-
-
-
-
-